<?php
/**
	Sponsor Manager (promotions.php file)
    Copyright (C) <Mon Apr 14 09:18:20 CEST 2008>  Marcos Ramírez <marcosramirez@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    
    Purpose:
    Last Modified:
**/

global $html;
global $promos;
global $sponsors;

// Process Post
if ($_POST) {
	switch($_POST['action']) {
		case 'addPromotionalContent':
			if ($_POST['promotionalType'] && $_POST['promotionalContent'] && $_POST['sponsor']) {
				$error=$promos->addPromotionalContent($_POST['promotionalType'], $_POST['promotionalContent'], $_POST['sponsor'], $_POST['multiplemode']);
				if (!$error)
					$html->addInfo(_('Content correctly added.'));
			}
			break;
			
		case 'addPromotionalType':
			if ($_POST['promotionalType'] && $_POST['description']) {
				$error=$promos->addPromotionalType($_POST['promotionalType'], $_POST['description']);
				if (!$error)
					$html->addInfo(_('Promotional Type correctly added'));	
			}			
			break;
			
		default:
			$html->addError(_('Unrecognized action'));
			break;
	}
}


$html->addCSSFile('promotions.css');
$html->addJSFile('promotions.js');
$html->header();
?>
<!-- promotional content -->
<p><a href="#" id="clickAddPromotionalContent">Add Promotional Content</a> - <a href="#" id="clickAddPromotionalType">Add Promotional Type</a></p>
<div id="addPromotionalContent">
<form method="post" action="<?php echo $Cfg['Sys']['webDir'].'?section=promotions'; ?>">
<p><?=_('Select Promotional Type')?></p><select name="promotionalType">
<? echo $promos->getPromotionalTypesOptions(); ?>
</select>
<p><?=_('Select Sponsor')?></p>
<select name="sponsor">
<? echo $sponsors->getSponsorListOptions(); ?>
</select>
<p><?=_('Copy&Paste promotional content (url, banner, etc)')?></p>
<p><input type="checkbox" name="multiplemode"><?=_('Multiple insert (Each line is a diferent content)')?></p>
<textarea name="promotionalContent"  cols="50" rows="20"></textarea>
<input type="hidden" name="action" value="addPromotionalContent" />
<input type="submit" value="<?php echo _('Submit Promotional Content') ;?>">
</form>
</div>
<!-- promotional type -->
<div id="addPromotionalType">
<form method="post" action="<?php echo $Cfg['Sys']['webDir'].'?section=promotions'; ?>">
Promotional Type: <input name="promotionalType" type="text" /><br />
Description:<input name="description" type="text" /><br />
<input type="hidden" name="action" value="addPromotionalType" />
<input type="submit" value="<?php echo _('Submit Promotional Type');?>" />
</form>
</div>

<?php
$html->footer();
?>